<?php

namespace App\Http\Controllers\Api\V1;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

// use App\Models\Authorization;
// use App\Transformers\AuthorizationTransformer;

class MessageController extends BaseController
{

    /*
     * 保存消息
     */
    public function show(Request $request, $spid)
    {
        if (empty($spid)) {
            return response()->json(['status' => '404', 'data' => '服务商ID不能为空!']);
        }
        $currentTime = date('Y-m-d H:i:s');
        // $currentTime = "2017-09-18 18:40:22";
        $messages = DB::table('messages')
            ->where('start_at', '<=', $currentTime)
            ->where('end_at', '>=', $currentTime)
            ->pluck('long_desc');
            // ->implode('。', 'long_desc');
        return response()->json(['status' => '200', 'data' => $messages]);
    }

    /*
     * 保存消息
     */
    public function store(Request $request, $spid)
    {
    }

    /**
     * 删除消息
     */
    public function delete(Request $request)
    {
    }

}
